<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="./css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<link rel="stylesheet" type="text/css" href="css/minemessage.css" />
		<style type="text/css">
			#head_img1 {
				position: absolute;
				bottom: 0.625rem;
				right: 0.3125rem;
				width: 2.5rem;
				height: 2.5rem;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">个人信息</h1>
		</header>
		<div class="mui-content">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a class="mui-navigate" id="head">
						<span class="minehead">头像</span>
						<span class="mui-pull-right head">
							<img class="head-img mui-action-preview" id="head_img1" src="./images/touxiang.jpg" />
						</span>
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a>姓名<span id="staffName" class="mui-pull-right"></span></a>
				</li>
				<li class="mui-table-view-cell">
					<a>账号<span id="staffAccount" class="mui-pull-right"></span></a>
				</li>
				<li class="mui-table-view-cell">
					<a>电话<span id="phoneNumber" class="mui-pull-right"></span></a>
				</li>
			</ul>
			<ul class="mui-table-view">
				<li class="mui-table-view-cell" style="text-align: center;">
					<a id="exit">退出登录</a>
				</li>
			</ul>
		</div>

		<script src="./js/mui.min.js"></script>
		<script src="./js/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<!-- <script src="http://103.59.149.116:6198/hcys/js/mapi.js" type="text/javascript" charset="utf-8"></script> -->
		<script src="js/Mobile.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<script type="text/javascript">
			var myStorage = JSON.parse(localStorage.getItem("users"));
			var glbToken = myStorage.glbToken;
			var staffId = myStorage.staffid;
			var userInfo = getStaffInfo(staffId, glbToken);
			var url = "http://103.59.149.116:6198/lnhy/";
			var imgUrl = userInfo.StaffImage;
			if (imgUrl != "") {
				if (imgUrl.substr(0, 2) == "..") {
					imgUrl = imgUrl.substr(2);
				}
				$("#head_img1").attr("src", url + imgUrl);
			}

			var staffName = document.getElementById("staffName");
			staffName.innerText = userInfo.StaffName;
			var staffAccount = document.getElementById("staffAccount");
			staffAccount.innerText = userInfo.StaffAccount;
			var phoneNumber = document.getElementById("phoneNumber");
			phoneNumber.innerText = userInfo.Phone;

			//退出操作******************
			document.getElementById('exit').addEventListener('tap', function() {
				if (mui.os.ios) {
					app.setState({});
					mui.openWindow({
						url: 'login.html',
						id: 'login',
						show: {
							aniShow: 'pop-in'
						},
						waiting: {
							autoShow: false
						}
					});
					return;
				}
				var btnArray = [{
					title: "注销当前账号"
				}, {
					title: "直接关闭应用"
				}];
				plus.nativeUI.actionSheet({
					cancel: "取消",
					buttons: btnArray
				}, function(event) {
					var index = event.index;
					switch (index) {
						case 1:
							//注销账号
							app.setState({});
							localStorage.removeItem("users");
							plus.runtime.restart();
							
							// var curr = plus.webview.currentWebview();
							// var wvs = plus.webview.all();
							// // for (var i = 0, len = wvs.length; i < len; i++) {
							// // 	//关闭除login页面外的其他页面
							// // 	if (wvs[i].id == "login") {
							// // 		plus.webview.close(wvs[i]);
							// // 	}
							// // }
							// var loginPage = mui.preload({
							// 	"url": 'login.html',
							// 	"id": 'login',
							// });
							// var login_loaded_flag = false;
							// loginPage.addEventListener("loaded", function() {
							// 	login_loaded_flag = true;
							// });
							// var id = setInterval(function() {
							// 	if (login_loaded_flag) {
							// 		clearInterval(id);
							// 		loginPage.show("login");
							// 	}
							// }, 20);
							// loginPage.onloaded = function() {
							// 	for (var i = 0, len = wvs.length; i < len; i++) {
							// 		//关闭除login页面外的其他页面
							// 		if (wvs[i].id == "login") {
							// 			plus.webview.close(wvs[i]);
										
							// 		}
							// 	}
							// 	// plus.webview.close(curr);
							// }
							
							plus.webview.getLaunchWebview().show("pop-in");
							break;
						case 2:
							plus.runtime.quit();
							plus.webview.close(plus.webview.all());
							break;
					}
				});
			}, false);
		</script>
	</body>

</html>
